package baseFx.tests.springboot;

import baseFx.springboot.FxSpringApplication;
import baseFx.springboot.MvcEvents;
import baseFx.springboot.components.AuthParam;
import baseFx.springboot.components.RequestAuth;
import baseFx.springboot.components.RequestAuthMapper;
import baseFx.springboot.components.RequestUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class TestRequestAuth extends RequestAuth {
    @Autowired
    private TestApp app;

    public TestRequestAuth(MvcEvents mvcEvents) {
        super(mvcEvents);
    }

    @Override
    protected RequestAuthMapper getMapper(HttpServletRequest request) {
        return new RequestAuthMapper() {
            @Override
            public RequestUser getUser(AuthParam param) {
                return new RequestUser(param.userId);
            }
        };
    }
}
